﻿using System;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.Collections.Generic;
using System.Text;
using PmuRegistry.Data;
using PmuRegistry.Data.Entities;
using System.IO;
using PmuRegistry.Data.BusinessObjects;

namespace PmuRegistry.Services.Service
{
	// NOTE: If you change the class name "PhasorDataService" here, you must also update the reference to "PhasorDataService" in Web.config.	
	[ServiceBehavior(IncludeExceptionDetailInFaults = false, AddressFilterMode = AddressFilterMode.Any)]
	public class PhasorDataService : IPhasorDataService
	{
		public Dictionary<string, string> GetTimeZones(bool isOptional)
		{
			return CommonFunctions.GetTimeZones(isOptional);
		}

		public Dictionary<int, string> GetNercRegions(bool isOptional)
		{
			return CommonFunctions.GetNercRegions(isOptional);
		}

		public Dictionary<int, string> GetDeviceStatuses()
		{
			return CommonFunctions.GetDeviceStatuses();
		}

		public Dictionary<int, string> GetContactTypes()
		{
			return CommonFunctions.GetContactTypes();
		}

		public List<WizardDeviceInfo> GetWizardConfigurationInfo(Stream inputStream)
		{
			return CommonFunctions.GetWizardConfigurationInfo(inputStream);
		}

		public string SaveWizardConfigurationInfo(List<WizardDeviceInfo> wizardDeviceInfoList, int protocolID, int companyID, int interconnectionID, int? parentID)
		{
			return CommonFunctions.SaveWizardConfigurationInfo(wizardDeviceInfoList, protocolID, companyID, interconnectionID, parentID);
		}

		public string GetExecutingAssemblyPath()
		{
			return CommonFunctions.GetExecutingAssemblyPath();
		}

		public string SaveIniFile(Stream input)
		{
			return CommonFunctions.SaveIniFile(input);
		}

		public bool UserIsValid(string userName, string password)
		{
			return CommonFunctions.UserIsValid(userName, password);
		}

        public Dictionary<int, string> GetFundingSources(bool isOptional)
        {
            return CommonFunctions.GetFundingSources(isOptional);
        }

		#region " Manage Device Code"
		
		public List<Device> GetDeviceList()
		{
			return CommonFunctions.GetDeviceList();
		}
		
		public List<Device> GetDeviceListByParentID(int parentID)
		{
			return CommonFunctions.GetDeviceListByParentID(parentID);
		}
		
		public Dictionary<int, string> GetDevices(DeviceType deviceType, bool isOptional)
		{
			return CommonFunctions.GetDevices(deviceType, isOptional);
		}
		
		public string SaveDevice(Device device, bool isNew, int digitalCount, int analogCount)
		{
			return CommonFunctions.SaveDevice(device, isNew, digitalCount, analogCount);
		}
		
		public Device GetDeviceByDeviceID(int deviceID)
		{
			return CommonFunctions.GetDeviceByDeviceID(deviceID);
		}
		
		public Device GetDeviceByAcronym(string acronym)
		{
			return CommonFunctions.GetDeviceByAcronym(acronym);
		}
		
		public Device GetConcentratorDevice(int deviceID)
		{
			return CommonFunctions.GetConcentratorDevice(deviceID);
		}

		public List<Device> GetRecentDevices()
		{
			return CommonFunctions.GetRecentDevices();
		}

		public Dictionary<string, int> GetReportingPmusStat()
		{
			return CommonFunctions.GetReportingPmusStat();
		}

		public Dictionary<string, int> GetPlannedPmusStat()
		{
			return CommonFunctions.GetPlannedPmusStat();
		}

		#endregion

		#region " Manage Phasor Code"

		public List<Phasor> GetPhasorList(int deviceID)
		{
			return CommonFunctions.GetPhasorList(deviceID);
		}

		public Dictionary<int, string> GetPhasors(bool isOptional)
		{
			return CommonFunctions.GetPhasors(isOptional);
		}

		public Dictionary<int, string> GetPhasorsByDevice(int deviceID, bool isOptional)
		{
			return CommonFunctions.GetPhasorsByDevice(deviceID, isOptional);
		}

		public string SavePhasor(Phasor phasor, bool isNew)
		{
			return CommonFunctions.SavePhasor(phasor, isNew);
		}

		#endregion

		#region " Manage Measurement Code"

		public List<Measurement> GetMeasurementList()
		{
			return CommonFunctions.GetMeasurementList();
		}

		public string SaveMeasurement(Measurement measurement, bool isNew)
		{
			return CommonFunctions.SaveMeasurement(measurement, isNew);
		}

		public List<Measurement> GetMeasurementsByDevice(int deviceID)
		{
			return CommonFunctions.GetMeasurementsByDevice(deviceID);
		}
		
		#endregion

		#region " Manage Contacts Code"

		public List<Contact> GetContactList(int companyID)
		{
			return CommonFunctions.GetContactList(companyID);
		}

		public string SaveContact(Contact contact, bool isNew)
		{
			return CommonFunctions.SaveContact(contact, isNew);
		}

		public Dictionary<int, string> GetTechnicalContactByCompany(int companyID, bool isOptional)
		{
			return CommonFunctions.GetTechnicalContactByCompany(companyID, isOptional);
		}

		#endregion

		#region " Manage Company Code"
		public List<Company> GetCompanyList()
		{
			return CommonFunctions.GetCompanyList();
		}
		public Dictionary<int, string> GetCompanies(bool isOptional)
		{
			return CommonFunctions.GetCompanies(isOptional);
		}
		public string SaveCompany(Company company, bool isNew)
		{
			return CommonFunctions.SaveCompany(company, isNew);
		}
		#endregion

		#region " Manage Vendor Code"
		public List<Vendor> GetVendorList()
		{
			return CommonFunctions.GetVendorList();
		}
		public Dictionary<int, string> GetVendors(bool isOptional)
		{
			return CommonFunctions.GetVendors(isOptional);
		}
		public string SaveVendor(Vendor vendor, bool isNew)
		{
			return CommonFunctions.SaveVendor(vendor, isNew);
		}
		#endregion

		#region " Manage Vendor Device Code"
		public List<VendorDevice> GetVendorDeviceList()
		{
			return CommonFunctions.GetVendorDeviceList();
		}
		public string SaveVendorDevice(VendorDevice vendorDevice, bool isNew)
		{
			return CommonFunctions.SaveVendorDevice(vendorDevice, isNew);
		}
		public Dictionary<int, string> GetVendorDevices(bool isOptional)
		{
			return CommonFunctions.GetVendorDevices(isOptional);
		}
		#endregion

		#region " Manage Interconnections Code"
		public Dictionary<int, string> GetInterconnections(bool isOptional)
		{
			return CommonFunctions.GetInterconnections(isOptional);
		}
		#endregion

		#region " Manage Protocols Code"

		public Dictionary<int, string> GetProtocols(bool isOptional)
		{
			return CommonFunctions.GetProtocols(isOptional);
		}

		#endregion

		#region " Manage Signal Types Code"

		public Dictionary<int, string> GetSignalTypes(bool isOptional)
		{
			return CommonFunctions.GetSignalTypes(isOptional);
		}

		#endregion	
	
		#region " Manage Network Model Code"

		public List<NetworkModel> GetNetworkModelList()
		{
			return CommonFunctions.GetNetworkModelList();
		}

		public Dictionary<int, string> GetNetworkModels(bool isOptional)
		{
			return CommonFunctions.GetNetworkModels(isOptional);
		}

		public string SaveNetworkModel(NetworkModel model, bool isNew)
		{
			return CommonFunctions.SaveNetworkModel(model, isNew);
		}

		#endregion

		#region " Manage User Comment Code"

		public List<UserComment> GetUserCommentList()
		{
			return CommonFunctions.GetUserCommentList();
		}

		public string SaveUserComment(UserComment comment)
		{
			return CommonFunctions.SaveUserComment(comment);
		}

		#endregion

	}
}
